home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 50
/
Volume 50 - JOGO DISK .iso
/
Games
/
marionettemadness.swf
/
scripts
/
frame_1
/
DoAction_6.as
< prev
next >
Wrap
Text File
|
2007-10-01
|
15KB
|
557 lines
function xmlLoaded()
{
_root.xmlBase = xmlDataContainer[xB][xPN];
xmlIsLoaded = true;
if(siteIsLoaded)
{
init();
}
}
function siteLoaded()
{
siteIsLoaded = init;
if(xmlIsLoaded)
{
nextFrame();
}
}
function resolveAngle(n)
{
return n < 360 ? (n >= 0 ? n : n + 360) : n - 360;
}
function mouseDistanceAngle(mc)
{
var _loc1_ = {x:handTarget._x,y:handTarget._y};
mc._parent.globalToLocal(_loc1_);
var _loc2_ = new Object();
_loc2_.rot = resolveAngle(Math.round(Math.atan2(_loc1_.y - mc._y,_loc1_.x - mc._x) * 180 / 3.141592653589793) + 90);
_loc2_.dist = Math.round(Math.sqrt(Math.pow(_loc1_.x - mc._x,2) + Math.pow(_loc1_.y - mc._y,2)));
return _loc2_;
}
function findIngredientFrame(n)
{
var _loc1_ = 0;
while(_loc1_ < ingredientList.length)
{
if(ingredientList[_loc1_] == n)
{
return _loc1_ + 1;
}
_loc1_ = _loc1_ + 1;
}
return -1;
}
function checkIngredient(clp)
{
trace("check " + clp);
removeMovieClip(clp);
for(var _loc3_ in cRoundIngredientClips)
{
trace(cRoundIngredientClips[_loc3_] + "==" + clp);
if(cRoundIngredientClips[_loc3_] == clp)
{
trace("found");
var _loc2_ = cRoundIngredientClips.splice(_loc3_,1);
redPanel.iCount.text = cRoundIngredientClips.length;
if(cRoundIngredientClips.length == 0)
{
endRound(true);
}
playSound("c" + Math.ceil(Math.random() * 4));
return true;
}
}
redPanel.clock.assessPenalty();
playSound("m" + Math.ceil(Math.random() * 4));
return false;
}
function emptyShelves()
{
lTgts = [topShelf,middleShelf,bottomShelf];
for(var _loc2_ in lTgts)
{
for(var _loc1_ in lTgts[_loc2_])
{
if(typeof lTgts[_loc2_][_loc1_] == "movieclip")
{
removeMovieClip(lTgts[_loc2_][_loc1_]);
}
}
}
}
function stockShelves(r)
{
var _loc5_ = undefined;
var _loc10_ = undefined;
var _loc8_ = undefined;
var _loc4_ = undefined;
var _loc1_ = undefined;
var _loc3_ = undefined;
var _loc2_ = undefined;
var _loc6_ = undefined;
var _loc7_ = undefined;
fullWidth = 500;
dTime = 0;
tTime = 0.4;
_loc5_ = roundIngredients[gameRound - 1];
_loc10_ = [topShelf,middleShelf,bottomShelf];
cRoundIngredientClips = new Array();
emptyShelves();
_loc4_ = 0;
while(_loc4_ < 3)
{
_loc3_ = _loc10_[_loc4_];
iWidth = 0;
_loc1_ = 0;
while(_loc1_ < _loc5_[_loc4_].length)
{
_loc2_ = _loc3_.attachMovie("ingredient","i" + _loc1_,_loc3_.getNextHighestDepth());
_loc2_.myIName = _loc5_[_loc4_][_loc1_];
_loc2_.iB.gotoAndStop(findIngredientFrame(_loc2_.myIName));
iWidth += _loc2_._width;
for(_loc8_ in cRoundIngredients)
{
if(cRoundIngredients[_loc8_] == _loc2_.myIName)
{
cRoundIngredientClips.push(_loc2_);
break;
}
}
_loc1_ = _loc1_ + 1;
}
_loc6_ = Math.round((fullWidth - iWidth) / _loc5_[_loc4_].length);
var _loc9_ = Math.round((iWidth + _loc6_ * (_loc5_[_loc4_].length - 1)) / 2);
_loc1_ = 1;
while(_loc1_ < _loc5_[_loc4_].length)
{
_loc7_ = _loc3_["i" + (_loc1_ - 1)]._x + _loc3_["i" + (_loc1_ - 1)]._width + _loc6_;
_loc2_ = _loc3_["i" + _loc1_];
_loc2_._x = _loc7_;
_loc1_ = _loc1_ + 1;
}
dTime += 0.2;
_loc3_._x = _loc3_.x0 + Math.round((fullWidth - _loc3_._width) / 2);
_loc4_ = _loc4_ + 1;
}
}
function moveRemy(v, h)
{
if(v != "n" && h != "n")
{
linguini.remy.gotoAndStop(v + h);
}
}
function currentShelf()
{
return crosshairs._y >= topShelf._y ? (crosshairs._y >= middleShelf._y ? bottomShelf : middleShelf) : topShelf;
}
function glowItem(mc, w)
{
if(w)
{
mc.nextFrame();
var _loc2_ = mc._totalframes;
}
else
{
mc.prevFrame();
_loc2_ = 1;
}
frameMe(mc,_loc2_,0.5);
}
function checkMouseOvers()
{
var _loc2_ = [topShelf,middleShelf,bottomShelf];
var _loc3_ = currentShelf();
var _loc5_ = lastArm != "left" ? (lastArm != "right" ? null : linguini.rightArm) : linguini.leftArm;
if(_loc5_)
{
var _loc6_ = false;
for(var _loc1_ in _loc3_)
{
if(typeof _loc3_[_loc1_] == "movieclip")
{
iHit = _loc5_.fingerTip.hitTest(_loc3_[_loc1_]);
if(iHit)
{
currentIngredient = _loc3_[_loc1_];
_loc6_ = true;
}
if(iHit && _loc3_[_loc1_]._currentframe == 1)
{
glowItem(_loc3_[_loc1_],true);
}
else if(!iHit && _loc3_[_loc1_]._currentframe == _loc3_[_loc1_]._totalframes)
{
glowItem(_loc3_[_loc1_],false);
}
}
}
if(!_loc6_)
{
currentIngredient = null;
}
}
for(_loc1_ in _loc2_)
{
if(_loc2_[_loc1_] != _loc3_)
{
for(var _loc4_ in _loc2_[_loc1_])
{
if(_loc2_[_loc1_][_loc4_]._currentframe == _loc2_[_loc1_][_loc4_]._totalframes)
{
_loc2_[_loc1_][_loc4_].gotoAndStop(_loc2_[_loc1_][_loc4_]._totalframes - 1);
frameMe(_loc2_[_loc1_][_loc4_],1,0.5);
}
}
}
}
fingerItem = currentIngredient;
}
function checkClick()
{
if(overShelves && gameOn && fingerItem)
{
checkIngredient(fingerItem);
}
}
function moveArms()
{
var _loc1_ = 10;
crosshairs._x = _xmouse;
crosshairs._y = _ymouse;
var _loc3_ = crosshairs._x <= handTarget._x + 1 ? (crosshairs._x >= handTarget._x - 1 ? "n" : "l") : "r";
var _loc5_ = crosshairs._y <= handTarget._y + 1 ? (crosshairs._y >= handTarget._y - 1 ? "n" : "u") : "d";
moveRemy(_loc5_,_loc3_);
xspace = (crosshairs._x - handTarget._x) / _loc1_;
yspace = (crosshairs._y - handTarget._y) / _loc1_;
if(Math.abs(xspace) > 0)
{
handTarget._x += xspace;
}
if(Math.abs(yspace) > 0)
{
handTarget._y += yspace;
}
if(handTarget._y > bottomCenter._y || handTarget._y < topCenter._y)
{
overShelves = false;
armNow = "none";
glowItem(currentIngredient,false);
currentIngredient = null;
crosshairs._alpha = 0;
Mouse.show();
}
else if(handTarget._x > topCenter._x && handTarget._x < topRight._x)
{
overShelves = true;
armNow = "right";
linguini.rightArm.moveMe();
crosshairs._alpha = 100;
Mouse.hide();
}
else if(handTarget._x < topCenter._x && handTarget._x > topLeft._x)
{
overShelves = true;
armNow = "left";
linguini.leftArm.moveMe();
crosshairs._alpha = 100;
Mouse.hide();
}
else
{
overShelves = false;
armNow = "none";
glowItem(currentIngredient,false);
currentIngredient = null;
crosshairs._alpha = 0;
Mouse.show();
}
if(lastArm != armNow)
{
if(armNow == "left")
{
var _loc4_ = linguini.leftArm.y0;
var _loc6_ = linguini.leftArm.s0;
var _loc7_ = linguini.rightArm.y0 + armDrop;
var _loc2_ = 50;
}
else if(armNow == "right")
{
_loc4_ = linguini.leftArm.y0 + armDrop;
_loc6_ = 50;
_loc7_ = linguini.rightArm.y0;
_loc2_ = linguini.rightArm.s0;
}
else
{
_loc4_ = linguini.leftArm.y0 + armDrop;
_loc6_ = 50;
_loc7_ = linguini.rightArm.y0 + armDrop;
_loc2_ = 50;
}
morphArm(linguini.leftArm,_loc4_,_loc6_,0.7);
morphArm(linguini.rightArm,_loc7_,_loc2_,0.7);
}
lastArm = armNow;
checkMouseOvers();
}
function startArmTracking()
{
this.onEnterFrame = function()
{
if(gameOn)
{
moveArms();
}
};
}
function calculateArmFrame(obj, dist)
{
return Math.round(Math.max(1,Math.min(100,(dist - obj.minDist) * 100 / obj.range)));
}
function prepLinguini()
{
linguini.leftArm.s0 = linguini.leftArm._yscale;
linguini.leftArm._yscale = armScale;
linguini.leftArm.y0 = linguini.leftArm._y;
linguini.leftArm._y += armDrop;
linguini.leftArm.minRot = linguiniData.leftArm_minRot;
linguini.leftArm.maxRot = linguiniData.leftArm_maxRot;
linguini.leftArm.minDist = linguiniData.leftArm_minDist;
linguini.leftArm.range = linguiniData.leftArm_maxDist - linguiniData.leftArm_minDist;
linguini.rightArm.s0 = linguini.rightArm._yscale;
linguini.rightArm._yscale = armScale;
linguini.rightArm.y0 = linguini.rightArm._y;
linguini.rightArm._y += armDrop;
linguini.rightArm.minRot = linguiniData.rightArm_maxRot;
linguini.rightArm.maxRot = linguiniData.rightArm_maxRot;
linguini.rightArm.minDist = linguiniData.rightArm_minDist;
linguini.rightArm.range = linguiniData.rightArm_maxDist - linguiniData.rightArm_minDist;
linguini.leftArm.moveMe = linguini.rightArm.moveMe = function()
{
var _loc2_ = this._parent._parent.mouseDistanceAngle(this);
_loc2_.rot = !(_loc2_.rot < this.minRot && _loc2_.rot >= 180) ? (!(_loc2_.rot > this.maxRot && _loc2_.rot < 180) ? _loc2_.rot : this.maxRot) : this.minRot;
this._rotation = _loc2_.rot;
var _loc3_ = this._parent._parent.calculateArmFrame(this,_loc2_.dist);
if(this._currentframe != _loc3_)
{
this.gotoAndStop(_loc3_);
}
};
}
function setButtonRO(o, s)
{
o.enabled = s;
o.rollMC._alpha = 0;
if(s)
{
o.onRollOver = function()
{
_root.buttonRoll(this,true);
};
o.onRollOut = o.onReleaseOutside = function()
{
_root.buttonRoll(this,false);
};
}
}
function beginRound(n)
{
turnGameOn();
crosshairs._alpha = 100;
startArmTracking();
slideMeY(linguini,linguini.yUp,0.7);
redPanel.clock.initTimer(roundTimes[gameRound]);
redPanel.clock.startTimer();
enableHints(true);
redPanel.helpMe._visible = true;
stopSounds();
playSound("inRound",10);
}
function initRound(n)
{
cRoundIngredients = new Array();
for(var _loc1_ in recipeIngredients[gameRound])
{
cRoundIngredients.push(recipeIngredients[gameRound][_loc1_]);
}
stockShelves(gameRound);
remainingIngs = redPanel.iCount.text = recipeIngredients[gameRound].length;
clockGoTo(redPanel.clock,1);
blackPanel.lev.text = "Level #" + gameRound;
blackPanel.big.text = roundBlackText[gameRound].b;
blackPanel.small.text = roundBlackText[gameRound].s;
if(blackPanel._y != blackPanel.yUp)
{
slideMeY(blackPanel,blackPanel.yUp,0.5,"easeOutBack");
slideMeY(redPanel,redPanel.yUp,0.5,"easeOutBack");
}
roundIntro.gotoAndPlay(2);
enableHints(false);
}
function startNextRound()
{
initRound(gameRound);
}
function getRecipes()
{
getUrl("javascript: pop(\'marionette_pdf\');", "");
}
function endRound(advance)
{
Mouse.show();
emptyShelves();
turnGameOff();
crosshairs._alpha = 0;
slideMeY(linguini,linguini.yDown,0.7);
slideMeY(blackPanel,blackPanel.yDown,0.5,"easeOutBack");
slideMeY(redPanel,redPanel.yDown,0.5,"easeOutBack");
_root.slideMeY(_root.buddies,_root.buddies.yDown,0.7,null,0.5);
var _loc2_ = !advance ? "loser" : (++gameRound <= 3 ? "nextLevel" : "winner");
messages.gotoAndStop(_loc2_);
redPanel.clock.pauseTimer();
slideMeY(messages,messages.yDown,0.7,"easeOutBack",0.5);
slideMeY(buddies,buddies.yUp,0.7,null,0.5);
redPanel.helpMe._visible = false;
stopSounds();
if(_loc2_ == "winner" || _loc2_ == "loser")
{
playSound(_loc2_);
}
else
{
playSound("end" + Math.ceil(Math.random() * 4));
}
playSound("soundtrack",100);
}
function turnGameOn()
{
gameOn = true;
blackPanel.helpMe._visible = false;
}
function turnGameOff()
{
gameOn = false;
blackPanel.helpMe._visible = false;
}
function restartGame()
{
hints = [null,true,true];
gameRound = 1;
initRound(gameRound);
}
function enableHints(b)
{
if(b)
{
redPanel.hint1.enabled = hints[1];
redPanel.hint2.enabled = hints[2];
if(hints[1])
{
dimMe(redPanel.hint1,0,0.5);
}
if(hints[2])
{
dimMe(redPanel.hint2,0,0.5);
}
}
else
{
redPanel.hint1.enabled = redPanel.hint2.enabled = b;
dimMe(redPanel.hint1,-75,0.5);
dimMe(redPanel.hint2,-75,0.5);
}
}
function showInstructions()
{
enableHints(false);
pauseTimer();
turnGameOff();
messages.gotoAndStop("instructions");
slideMeY(messages,messages.yDown,0.7,"easeOutBack",0.5);
redPanel.helpMe._visible = false;
}
function hideHint()
{
enableHints(true);
turnGameOn();
startTimer();
hintBTN._alpha = hintBTN._visible = 0;
slideMeY(linguini,linguini.yUp,0.7);
for(var _loc1_ in cRoundIngredientClips)
{
tintMe(cRoundIngredientClips[_loc1_],0,0.7);
}
slideMeY(messages,messages.yUp,0.7,"easeOutBack",0.5);
redPanel.helpMe._visible = true;
}
function displayHint(n)
{
handTarget._x = 1;
redPanel.hint1.enabled = redPanel.hint2.enabled = hints[n] = false;
redPanel["hint" + n].rollMC._alpha = 0;
dimMe(redPanel["hint" + n],-75,0.5);
for(var _loc1_ in cRoundIngredientClips)
{
tintMe(cRoundIngredientClips[_loc1_],50,1);
}
slideMeY(linguini,linguini.yDown,1);
hintBTN._alpha = 0;
hintBTN._visible = true;
alphaMe(hintBTN,100,0.5,null,0.4);
pauseTimer();
turnGameOff();
}
function buildFramework()
{
slideMeXY(siteLogo,siteLogo.xN,siteLogo.yN,0.7,"easeOutBack");
slideMeY(gameLogo,gameLogo.yDown,0.7,"easeOutBack");
slideMeY(messages,messages.yDown,0.7,"easeOutBack",0.5);
slideMeX(soundControl,soundControl.xRight,0.7,"easeOutBack",0.5);
slideMeY(buddies,buddies.yUp,0.7,null,0.5);
}
function clockGoTo(i, f)
{
i.gotoAndStop(f);
i.clockBlack.gotoAndStop(f);
}
function clockTweenTo(i, f)
{
trace("tween " + i + " to " + f);
frameMe(i,f * 10,1);
frameMe(i.clockBlack,f * 10,1);
}
function startTimer()
{
redPanel.clock.startTimer();
}
function pauseTimer()
{
redPanel.clock.pauseTimer();
}
function init()
{
buildFramework();
topShelf.x0 = topShelf._x;
middleShelf.x0 = middleShelf._x;
bottomShelf.x0 = bottomShelf._x;
prepLinguini();
setButtonRO(closeBtn,true);
closeBtn.onRelease = function()
{
getUrl("javascript:window.close();", "");
};
var _loc2_ = new Object();
_loc2_.onMouseDown = function()
{
_root.checkClick();
};
Mouse.addListener(_loc2_);
}
_global.getMCLoadPCT = function(clp)
{
var _loc1_ = clp;
return _loc1_.getBytesLoaded() <= 50 ? 1 : _loc1_.getBytesLoaded() / _loc1_.getBytesTotal();
};